import {createRouter,createWebHashHistory} from "vue-router";
import {useLoginStore} from "./stores/LoginStore.js";
//路由配置
const routes =[
    // {
    //     path:"/login",
    //     name:"Login",
    //     component:()=>import ('./pages/login/Index.vue'),
    //     meta:{
    //         noLogin:true
    //     }
    // },
    {
    path: "/",
    name:"Home",
        component:()=>import ('./pages/home/Index.vue'),
      children:[
          {
              path:"/home",
              name:"Home",
              component:()=>import ('./pages/home/home/Index.vue'),
          },
          {
              path:"/bill",
              name:"Bill",
              component:()=>import ('./pages/home/bill/Index.vue'),
          },
          {
              path:"/user",
              name:"User",
              component:()=>import ('./pages/home/user/Index.vue'),
          },
          {
              path:"/customer",
              name:"Customer",
              component:()=>import ('./pages/home/customer/Index.vue'),
          },
          {
              path:"/authority",
              name:"Authority",
              component:()=>import ('./pages/home/authority/Index.vue'),
          },
          {
              path:"/role",
              name:"Role",
              component:()=>import ('./pages/home/role/Index.vue'),
          },
          {
              path:"/depository",
              name:"Depository",
              component:()=>import ('./pages/home/depository/Index.vue'),
          },
          {
              path:"/driver",
              name:"Driver",
              component:()=>import ('./pages/home/driver/Index.vue'),
          },
          {
              path:"/goods",
              name:"Goods",
              component:()=>import ('./pages/home/goods/Index.vue'),
          },
          {
              path:"/line",
              name:"Line",
              component:()=>import ('./pages/home/line/Index.vue'),
          },
          {
              path:"/order",
              name:"Order",
              component:()=>import ('./pages/home/order/Index.vue'),
          },
          {
              path:"/package",
              name:"Package",
              component:()=>import ('./pages/home/package/Index.vue'),
          }
      ]
    },


]


const router = createRouter({
    history: createWebHashHistory(),
    routes
})
//导航守卫
// router.beforeEach((to, from) => {
//     const loginStore = useLoginStore()
//     //检查是否登录
//     if (to.meta.noLogin) {
//         return true
//     }
//     if (!loginStore.isLogin) {
//         return  {name: 'Login'}
//     }
//     return  true
// })
export default router